package com.qf2210.group.three.server.controller;


import com.qf2210.group.three.pojo.TbUser;
import com.qf2210.group.three.server.service.TbUserService;
import com.qf2210.group.three.utils.JsonResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class LoginController {
    @Autowired
    private TbUserService tbUserService;
    @PostMapping(path = "dologin")
    public JsonResult login(@RequestBody TbUser tbUser){
        JsonResult jsonResult=new JsonResult();
        TbUser login = tbUserService.login(tbUser);
        if (login!=null){
            jsonResult.setData(login);
        }else{
            jsonResult.setErrorCode(500);
            jsonResult.setErrorMessage("登录失败！");
        }
        return  jsonResult;
    }
}
